<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>药品新增（生产企业端）</title>

<%@ include file="/WEB-INF/component/commonCSS.jsp" %> 


</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>药品新增</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
            <li class="active"><a href="#">招标采购管理</a></li>
            <li class="active"><a href="#">投标药品信息管理</a></li>
            <li class="active"><a href="#">药品申报</a></li>
        </ol>
    </section>
    <section class="content">
        <div class=" box box-success">
            <div class="box-header"></div>
            <form  id="form1" class="form-horizontal" action="${ctx}/prodDrug/saveProdDrug.html" method="post">
                <input class="form-control" id="projId" name="projId" type="hidden"  value="${projId}">
                <div class="box-body">
                
                    <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span>药品编码：</label>
                         <div class="col-sm-4 text-left">
                            <input class="form-control" id="drugCode" name="drugCode" placeholder="药品编码" type="text">
                        </div>
                        
                        <label class="col-sm-2 text-right"><span class="required">*</span>通用名：</label>
                        <div class="col-sm-4 text-left">
                            <input onclick="quality();" class="form-control" readonly="readonly" id="qualityspecName" name="qualityspecName" placeholder="通用名" type="text" ">
                        </div>
                    </div>
                    
                    <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right">通用名英文：</label>
                        <div class="col-sm-4 text-left">
                            <input onclick="quality();"  class="form-control" readonly="readonly" id="qualityspecNameEng" name="qualityspecNameEng" placeholder="通用名英文" type="text">
                        </div>
                        
                        <label class="col-sm-2 text-right">商品名：</label>
                        <div class="col-sm-4 text-left">
                            <input class="form-control" id="busName" name="busName"  placeholder="商品名" type="text">
                        </div>
                    </div>
                    
                    <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span>剂型：</label>
                        <div class="col-sm-4 text-left">
                            <input onclick="quality();" class="form-control" readonly="readonly" id="form" name="form" placeholder="剂型" type="text" ">
                        </div>
                        
                        <label class="col-sm-2 text-right"><span class="required">*</span>规格：</label>
                        <div class="col-sm-4 text-left">
                            <input onclick="quality();" class="form-control" readonly="readonly" id="spec" name="spec" placeholder="规格" type="text" ">
                        </div>
                    </div>
                    
                    <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span>转换系数：</label>
                        <div class="col-sm-4 text-left">
                            <input class="form-control" id="factor" name="factor" placeholder="转换系数，没有请填1"  type="text">
                        </div>
                        
                        <label class="col-sm-2 text-right"><span class="required">*</span>包装单位：</label>
                        <div class="col-sm-4 text-left">
                            <input onclick="stdUnit();" class="form-control" readonly="readonly" id="unit" name="unit" placeholder="单位"  type="text">
                        </div>
                    </div>
                    
                    <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span>材质：</label>
                        <div class="col-sm-4 text-left">
                             <input onclick="material();" class="form-control" readonly="readonly" id="materialName" name="materialName" placeholder="材质"  type="text">
                        </div>
                        
                        <label class="col-sm-2 text-right"><span class="required">*</span>药品本位码：</label>
                        <div class="col-sm-4 text-left">
                              <input class="form-control" id="drugStdCode" name="drugStdCode" placeholder="药品本位码" type="text"">
                        </div>
                        
                    </div>
                    
                    <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span>批准文号：</label>
                        <div class="col-sm-4 text-left">
                            <input class="form-control" id="approvalCode" name="approvalCode" placeholder="批准文号" type="text" >
                        </div>
                        
                        <label class="col-sm-2 text-right"><span class="required">*</span>批准日期：</label>
                        <div class="col-sm-4 text-left">
                         <input class="form-control" type="text" id="approvalDate" name="approvalDate"   placeholder="yyyy-MM-dd" data-provide="datepicker" data-date-fmt="yyyy-MM-dd" />
                        </div>
                    </div>
                   
                    <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span>基本药物属性：</label>
                        <div class="col-sm-4 text-left">
                            <select class="form-control" id="drugAttr" name="drugAttr">
                                <option value="">请选择</option>
                                <option value="1" >国家基本药物（2012版）</option>
                                <option value="2" >省增补基本药物</option>
                                <option value="3" >其他</option>
                            </select>
                        </div>
                        
                        <label class="col-sm-2 text-right">基药序号：</label>
                        <div class="col-sm-4 text-left">
                            <input class="form-control" id="drugIndex" name="drugIndex" placeholder="基药序号" type="text"  />
                        </div>
                    </div>
                        
                   <div class="form-group form-group-xs">
                      <label class="col-sm-2 text-right"><span class="required">*</span>药理分类：</label>
                      <div class="col-sm-4 text-left">
                            <input onclick="dicPhar();" class="form-control" readonly="readonly" id="pharName" name="pharName" placeholder="药理分类" type="text">
                       </div>
                      
                       <label class="col-sm-2 text-right"><span class="required">*</span>专利类型：</label>
                       <div class="col-sm-4 text-left">
                           <select class="form-control" id="patternType" name="patternType">
                                <option value="">请选择</option>
                                <option value="1" >发明专利</option>
                                <option value="2" >实用新型专利</option>
                                <option value="3" >外观设计专利</option>
                                <option value="4" >没有专利</option>
                                <option value="9" >不详</option>
                           </select>
                       </div>
                   </div>
                        
                   <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span>药品来源：</label>
                        <div class="col-sm-4 text-left">
                                <select class="form-control" id="drugSource" name="drugSource">
                                    <option value="">请选择</option>
                                    <option value="1">国产</option>
                                    <option value="2">进口</option>
                                    <option value="9">不详</option>
                                </select>
                            
                        </div>
                        
                        <label class="col-sm-2 text-right"><span class="required">*</span>是否低价药：</label>
                        <div class="col-sm-4 text-left">
                            <select class="form-control" id="isLowprice" name="isLowprice">
                                <option value="">请选择</option>
                                <option value="1">是</option>
                                <option value="0">否</option>
                                <option value="9">未知</option>
                            </select>
                        </div>
                   </div>
                        
                   <div class="form-group  form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span>是否农合：</label>
                        <div class="col-sm-4 text-left">
                             <select class="form-control" id="isAgriculture" name="isAgriculture">
                                 <option value="">请选择</option>
                                 <option value="1">是</option>
                                 <option value="0">否</option>
                                 <option value="9">未知</option>
                             </select>
                         </div>
                         
                         <label class="col-sm-2 text-right"><span class="required">*</span>是否医保：</label>
                         <div class="col-sm-4 text-left">
                              <select class="form-control" id="isHealthcare" name="isHealthcare">
                                   <option value="">请选择</option>
                                   <option value="1">是</option>
                                   <option value="0">否</option>
                                   <option value="9">未知</option>
                              </select>
                         </div>
                    </div>
                        
                    
                       
                     <div class="form-group form-group-xs">
                          <label class="col-sm-2 text-right">药品本位码备注：</label>
                          <div class="col-sm-10 text-left">
                               <textarea class="form-control" id="drugStdcdRemark" name="drugStdcdRemark" rows="3" placeholder="药品本位码备注" ></textarea> 
                          </div>
                     </div>
                       
                     <div class="form-group form-group-xs">
                          <label class="col-sm-2 text-right">说明：</label>
                          <div class="col-sm-10 text-left">
                               <textarea class="form-control" id="remark" name="remark" rows="3" placeholder="说明 ..."></textarea>
                          </div>
                     </div>
                     
                      <!-- 隐藏的ID -->
                     <div class="form-group form-group-xs" style="display: none" >
                         <label class="col-sm-2 text-right">品规ID：</label>
                         <div class="col-sm-4 text-left">
                               <input  class="form-control" id="qualityspecId" name="qualityspecId" placeholder="品规ID" type="text" value="${form.qualityspecId }">
                         </div>
                    </div>
                    <div class="form-group form-group-xs" style="display: none"  >
                         <label class="col-sm-2 text-right">材质ID：</label>
                         <div class="col-sm-4 text-left">
                               <input class="form-control" id="materialId" name="materialId" placeholder="材质ID" type="text" value="${form.materialId }">
                         </div>
                         <label class="col-sm-2 text-right">药理分类ID：</label>
                         <div class="col-sm-4 text-left">
                               <input class="form-control" id="pharId" name="pharId" placeholder="药理分类ID" type="text" value="${form.pharId }">
                               
                         </div>
                    </div>
                     
                        
                     <div class="box-footer text-center">
                        <button type="button" onclick="save();" class="btn btn-success btn-sm">保&nbsp;存</button>
                        <a href="${ctx}/prodDrug/toProdDrugList.html?projId=${projId}" class="btn btn-danger btn-sm">返  回</a>
                     </div>
                </div>
            </form>
        </div>
    </section>
    <%@ include file="/WEB-INF/component/commonJS.jsp" %> 
    <script type="text/javascript">
        
         //保存
         function save() {
            if (!validate()) {
                return;
            }  
            
            $.HN.message.confirm('确定要保存吗？', '', '').on(function (e) {
               if (e) {
                        $("#form1").ajaxSubmit({
                            dataType : "json",
                            timeout: 10000,
                            success : function(result, statusText) {
                                if (result.success) {
                                    $.HN.message.alert("操作成功！", "消息", "success", function() {
                                        document.location = "${ctx}/prodDrug/toProdDrugList.html?projId=${projId}";
                                    });
                                } else {
                                    $.HN.message.alert(result.msg || "操作失败", "消息", "error");
                                }
                            }
                        });
                   }
              });
            
        }
        
      
      
    //通用名、剂型、规格弹窗
      function quality(){
            var url = "${ctx}/prodDrug/toDrugSelectQualityspec.html?projId=${projId}";
          $.HN.dialog.open({
              "id": "quality",
              "title": "品规列表", 
              "url": url, 
              "data": {}, 
              "width": 800, 
              "height": 510, 
              "closefunc":function(params) {
                  if (params) {
                      $("#qualityspecId").val(params.qualityspecId);
                      $("#spec").val(params.spec);
                      $("#form").val(params.form);
                      $("#qualityspecName").val(params.qualityspecName);
                  }
              }
          });   
      }
      
    
       //药理分类 弹窗
      function dicPhar() {
           var url = "${ctx}/prodDrug/toDrugSelectPhar.html";
          $.HN.dialog.open({
              "id": "dicPhar",
              "title": "药理分类列表", 
              "url": url, 
              "data": {}, 
              "width": 800, 
              "height": 510, 
              "closefunc":function(params) {
                  if (params) {
                      $("#pharName").val(params.pharName);
                      $("#pharId").val(params.pharId);
                  }
              }
          }); 
      }
  
    //材质  弹窗
      function material() {
           var url = "${ctx}/prodDrug/toDrugSelectMaterial.html";
          $.HN.dialog.open({
              "id": "material",
              "title": "材质列表", 
              "url": url, 
              "data": {}, 
              "width": 800, 
              "height": 510, 
              "closefunc":function(params) {
                  if (params) {
                      $("#materialName").val(params.materialName);
                      $("#materialId").val(params.materialId);
                  }
              }
          }); 
      }
    
      //单位  弹窗
      function stdUnit() {
           var url = "${ctx}/prodDrug/toDrugSelectUnit.html";
          $.HN.dialog.open({
              "id": "stdUnit",
              "title": "包装单位列表", 
              "url": url, 
              "data": {}, 
              "width": 800, 
              "height": 510, 
              "closefunc":function(params) {
                  if (params) {
                      $("#unit").val(params.unit);
                  }
              }
          }); 
      }
      
      
      
    //效验
      function validate() {
          
          var drugCode = $.trim($("#drugCode").val());
          if (drugCode == null || drugCode == "") {
              $.HN.message.alert("药品编码不能为空！请输入", "提示信息", "warn");
              return false;
          } else if (!/^[a-zA-Z0-9_]+$/.test(drugCode)) {
              $.HN.message.alert("药品编码只能由字母数字下划线组成！", "提示信息", "warn");
              return false;
          }
          
          var qualityspecName = $.trim($("#qualityspecName").val());
          if (qualityspecName == null || qualityspecName == "") {
              $.HN.message.alert("通用名不能为空！请点击弹窗选择", "提示信息", "warn");
              return false;
          }
          
          var form = $.trim($("#form").val());
          if (form == null || form == "") {
              $.HN.message.alert("剂型不能为空！请点击弹窗选择", "提示信息", "warn");
              return false;
          }
          
          var spec = $.trim($("#spec").val());
          if (spec == null || spec == "") {
              $.HN.message.alert("规格不能为空！请点击弹窗选择", "提示信息", "warn");
              return false;
          }
          
          var factor = $.trim($("#factor").val());
          if (factor == null || factor == "") {
              $.HN.message.alert("转换系数不能为空！请输入", "提示信息", "warn");
              return false;
          }else if (!/^[0-9]+$/.test(factor)) {
              $.HN.message.alert("转换系数只能由数字组成！", "提示信息", "warn");
              return false;
          }
          
          var unit = $.trim($("#unit").val());
          if (unit == null || unit == "") {
              $.HN.message.alert("单位不能为空！请输入", "提示信息", "warn");
              return false;
          }
          
          var materialName = $.trim($("#materialName").val());
          if (materialName == null || materialName == "") {
              $.HN.message.alert("材质不能为空！请点击弹窗选择", "提示信息", "warn");
              return false;
          }
          
          
          var approvalCode = $.trim($("#approvalCode").val());
          if (approvalCode == null || approvalCode == "") {
              $.HN.message.alert("批准文号不能为空！请输入", "提示信息", "warn");
              return false;
          }
          
          var approvalDate = $.trim($("#approvalDate").val());
          if (approvalDate == null || approvalDate == "") {
              $.HN.message.alert("批准日期不能为空！请点击选择", "提示信息", "warn");
              return false;
          }
          
          var drugAttr = $.trim($("#drugAttr").val());
          if (drugAttr == null || drugAttr == "") {
              $.HN.message.alert("基本药物属性不能为空！请点击选择", "提示信息", "warn");
              return false;
          }
          
         var drugIndex = $.trim($("#drugIndex").val());
          if (drugIndex != null && drugIndex != "" && !/^[0-9]+$/.test(drugIndex)) {
              $.HN.message.alert("基药序号只能由数字组成！", "提示信息", "warn");
              return false;
          } 
          
          var pharName = $.trim($("#pharName").val());
          if (pharName == null || pharName == "") {
              $.HN.message.alert("药理分类不能为空！请点击弹窗选择", "提示信息", "warn");
              return false;
          }
          
          var patternType = $.trim($("#patternType").val());
          if (patternType == null || patternType == "") {
              $.HN.message.alert("专利类型不能为空！请点击选择", "提示信息", "warn");
              return false;
          }
          
          var drugSource = $.trim($("#drugSource").val());
          if (drugSource == null || drugSource == "") {
              $.HN.message.alert("药品来源不能为空！请点击选择", "提示信息", "warn");
              return false;
          }
          
          var isLowprice = $.trim($("#isLowprice").val());
          if (isLowprice == null || isLowprice == "") {
              $.HN.message.alert("是否低价药不能为空！请点击选择", "提示信息", "warn");
              return false;
          }
          
          var isAgriculture = $.trim($("#isAgriculture").val());
          if (isAgriculture == null || isAgriculture == "") {
              $.HN.message.alert("是否农合不能为空！请点击选择", "提示信息", "warn");
              return false;
          }
          
          var isHealthcare = $.trim($("#isHealthcare").val());
          if (isHealthcare == null || isHealthcare == "") {
              $.HN.message.alert("是否医保不能为空！请点击选择", "提示信息", "warn");
              return false;
          }
          
          var drugStdCode = $.trim($("#drugStdCode").val());
          if (drugStdCode == null || drugStdCode == "") {
              $.HN.message.alert("药品本位码不能为空！请输入", "提示信息", "warn");
              return false;
          }

          return true;
      }
       
    </script>
</body>
</html>